package org.okcjug.december.collections;


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

import junit.framework.TestCase;

import org.junit.Before;

public class MyCollectionsTest extends TestCase
{
	private List<String> coll1;
	private List<String> coll2;
	
	@Before
	public void setUp() throws Exception 
	{
		coll1 = new ArrayList<String>();
		coll1.add("A");
		coll1.add("B");
		coll1.add("C");
		
		coll2 = new ArrayList<String>();
		coll2.add("E");
		coll2.add("F");
		coll2.add("G");
	}
	
	public void _test_Disjoint()
	{
		assertTrue("expected the 2 collections to not have anything in common", 
				Collections.disjoint(coll1, coll2));
		
		coll1.add("F");
		
		assertFalse("expected the 2 collections to have something in common", 
				Collections.disjoint(coll1, coll2));
	}
	
	public void _test_empty()
	{
		List<String> s = Collections.emptyList();

		try
		{
			s.add("asdf");
			fail("s.add should have thrown an exception");
		}
		catch (UnsupportedOperationException e)
		{
			e.printStackTrace();
		}
	}
	
	public void _test_frequency()
	{
		coll2 = new ArrayList<String>();
		coll2.add("A");
		coll2.add("B");
		coll2.add("C");
		
		System.err.println("coll1: " + coll1);
		System.err.println("coll2: " + coll2);
		
		assertEquals(1, Collections.frequency(coll1, "B"));
		
		
	}

	public void _test_min_max()
	{
		System.err.println("min: " + Collections.min(coll1));
		System.err.println("max: " + Collections.max(coll1));
	}

//		rotate bs wheel of fish - shirt give away
	public void test_rotate()
	{
		coll1 = new ArrayList<String>();
		coll1.add("Brent W. Wilkins");
		coll1.add("David Emler");
		coll1.add("Derrick Parkhurst");
		coll1.add("Doug Burke");
		coll1.add("farhana reid");
		coll1.add("Francine Konen");
		coll1.add("Fred Cook");
		coll1.add("Gary Tipton");
		coll1.add("Grzegorz Bugaj");
		coll1.add("Harsath Arif");
		coll1.add("Hobi HaQue");
		coll1.add("Jackie F. Oram");
		coll1.add("James Fowler");
		coll1.add("Jason Lee");
		coll1.add("Jeff Bowman");
		coll1.add("Jobby Joseph");
		coll1.add("John Ta");
		coll1.add("Kasumi A");
		coll1.add("Kathy Wheeler");
		coll1.add("Marion D. Dilbeck");
		coll1.add("Michael Smith");
		coll1.add("Mitch Blevins");
		coll1.add("Monte Schibbelhute");
		coll1.add("ODILON SENYANA");
		coll1.add("Praveen Vajjha");
		coll1.add("Regina LaRue");
		coll1.add("Robert McFarland");
		coll1.add("Ryan Hoegg");
		coll1.add("Scott Centille");
		coll1.add("Sharon Davis");
		coll1.add("Sharon McAllister");
		coll1.add("Stephanie Wade");
		coll1.add("Timothy Davenport");
		coll1.add("Tonii D Christopher");
		coll1.add("Walter Jones");
		
		System.err.println(coll1.size() + "  " + coll1);
//		
//		Random r = new Random();
//
//		int int1 = r.nextInt(coll1.size());
//		Collections.rotate(coll1, int1);
//		System.err.println("1  " + int1 + "  " + coll1);
//		
//		int1 = r.nextInt(coll1.size());
//		Collections.rotate(coll1, int1);
//		System.err.println("2  " + int1 + "  " + coll1);
//
//		int1 = r.nextInt(coll1.size());
//		Collections.rotate(coll1, int1);
//		System.err.println("3  " + int1 + "  " + coll1);
//
//		int1 = r.nextInt(coll1.size());
//		Collections.rotate(coll1, int1);
//		System.err.println("4  " + int1 + "  " + coll1);
//
//		int1 = r.nextInt(coll1.size());
//		Collections.rotate(coll1, int1);
//		System.err.println("5  " + int1 + "  " + coll1);
//		
//		System.err.println("****************************");
//		System.err.println("**   and the winner is    **");
//		System.err.println("** " + coll1.get(0) + "   **");
//		System.err.println("****************************");
		
		
	}
}
